<template>
<!-- 选择图片：兼容处理 -->
  <uni-popup ref="popup" type="bottom">
    <view class="popup-box">
      <view class="pop-content" v-for="(item,index) in chooseItems[type]" :key="index">
        <view class="show-list" @click="getVal(item.code)">{{item.value}}</view>
      </view>
    </view>
  </uni-popup>
</template>

<script>
import uniPopup from "../uni-popup/uni-popup.vue";
/**
 * 确认对话框
 * @prop title 标题
 * @prop text 提示内容
 * @prop cancelText 取消按钮文字
 * @prop confirmText 确认按钮文字
 * @event onConfirm 确认按钮点击时触发
 */
export default {
  components: { uniPopup },
  data() {
    return {};
  },
  props: {
    type: {
      type: String,
      default: 'take'
    }
  },
  data () {
    return {
      chooseItems: {
        'take': [
          {
            code: '1',
            value: '拍摄'
          },
          {
            code: '2',
            value: '从相册选择'
          },
          {
            code: '0',
            value: '取消'
          }
        ]
      }
    }
  },
  methods: {
    getVal (val) {
      this.$emit('getVal', val)
      this.$refs.popup.close()
    },
    open() {
      this.$refs.popup.open();
    },
    close() {
      this.$emit("onClose")
      this.$refs.popup.close()
    }
  }
}
</script>

<style scoped lang='scss'>
.popup-box {
  width: 750rpx;
  height: 300rpx;
  border-radius: 50rpx 50rpx 0 0;
  background-color: $uni-bg-color-grey;
  .pop-content {
    line-height: 100rpx;
    height: 100rpx;
    font-size: 36rpx;
    text-align: center;
    vertical-align: middle;
  }
}
</style>
